package com.study.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.study.common.DateUtils;
import com.study.model.pojo.SaleOrder;
import com.study.services.SaleOrderServices;

@RestController
@RequestMapping("/saleorder")
public class SaleOrderController {
	@Autowired
	SaleOrderServices sos;
	
	@RequestMapping("/soInfo")
	public JSONArray saleInfo() {
		System.out.println("soInfo");
		JSONArray json = new JSONArray();
		List<SaleOrder> saleOrders = sos.selectAll();
		for (SaleOrder saleOrder : saleOrders) {
			JSONObject jObject = new JSONObject();
			jObject.put("saleOrderId", saleOrder.getSaleOrderId());
			jObject.put("recId", saleOrder.getRecId());
			jObject.put("soData", DateUtils.dateFormat(saleOrder.getSoData()));
			jObject.put("deptno", saleOrder.getDeptno());
			jObject.put("proId", saleOrder.getProId());
			jObject.put("saleOrderTotal", saleOrder.getSaleOrderTotal());
			jObject.put("eid", saleOrder.getEid());
			jObject.put("soState", saleOrder.getSoState());
			jObject.put("sodId", saleOrder.getSodId());
			
			json.add(jObject);
		}
		return json;
	}
	
	

	
}
